package org.kolonitsky.translator.filter;

import org.kolonitsky.translator.Settings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author Alex.Kolonitsky
 */

public class DefaultFilter implements Filter {

    protected static final Log LOG = LogFactory.getLog(DefaultFilter.class);

    public boolean shouldTranslate(String text) {
        if (text == null) {
            return false;
        }

        String trim = text.trim();
        if (trim.length() == 0 || trim.matches(Settings.TRANSLATION_EXCLUDE_PATTERN) || Settings.TRANSLATION_EXCLUDE_MAP_KEYS.contains(trim)) {
            LOG.debug("translate - no   - '" + text + "'");
            return false;
        }
        return true;
    }
}
